<?php

namespace app\common\model;

use EasyWeChat\Factory;
use think\Exception;
use think\Model;

/**
 * 邮箱验证码
 */
class NoticeModel extends Model
{
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
    protected $name = 'notice';


    public function getList()
    {
        $list = self::where(['status' => 1,'is_recommend'=>1])->order('sort desc create_time desc')->field('id,title')->limit(6)->select();
        return ['code' => 200, 'msg' => '获取信息成功', 'data' => $list];
    }





    public function getLists($params)
    {
        $list = self::where(['status' => 1])->order("sort desc create_time desc")->paginate($params['limit'], false, ['page' => $params['page']]);

        return ['code' => 200, 'msg' => '获取信息成功', 'data' => $list];
    }


    public function getDetail($params)
    {
        $list = self::where(['status' => 1, 'id' => $params['id']])->field('id,title,content')->find();
        $list['content'] = (new DistrictsModel())->get_img_thumb_url($list['content'],config('app.api_url'));
        return ['code' => 200, 'msg' => '获取信息成功', 'data' => $list];
    }

}
